#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <omp.h>
#include <mpi.h>
#include <time.h>

#define NT 4
#define NE 10000
#define VERBOSE 0
#define NE_DEFAULT 10000
#define NTDS_DEFAULT 4

struct mesh
{
  char *le;
  char *re;
  char *org_le;
  char *org_re;
  int blk_num;
  int blk_sz;
  int elem_sz;
  int ntds;
};
typedef struct mesh *MESH;

struct splt 
{
  char *le;
  char *re;
  int  lf;
  int  rf;
  int id;
};
typedef struct splt *SPLT;

MESH initMesh(const void *, int, int, int);
SPLT initGlobalSplt(MESH);
SPLT initLocalSplt(MESH, int);
int  updateMesh(SPLT, MESH);
int  updateGlobalSplt(SPLT ls, SPLT gs);
int isKeyFound(const void* key, int (*compar)(const void *, const void *), SPLT);
int userComparOperator(const void *, const void *);
void printMesh(MESH me);
void printSplt(SPLT s);
void deleteSplt(SPLT *);
void deleteMesh(MESH *);
int  getKeyID(MESH, SPLT);

int omp_bsearch
(
 const void* key, 
 const void* base, 
 size_t num, 
 size_t size,
 int (*compar)(const void *, const void *), 
 int ntds                                   
 );

int mpi_bsearch
(
 const void *key, 
 const void *base, 
 size_t num, 
 size_t size, 
 int (*compar)(const void *, const void *), 
 MPI_Comm comm, 
 int ntds
);
